﻿using MediatR;
using T_Material.API.Application.Commands.PurchaseCommand;
using T_Material.API.Application.Commands.WarehousingCommand;
using T_Material.Infrastructure.ImpI;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.WarehousingHandlers
{
    public class WarehousingDeleteCommandHandler : IRequestHandler<WarehousingDeleteCommand, int>
    {
        private readonly IWarehousingRepository warehousingRepository;
        public WarehousingDeleteCommandHandler(IWarehousingRepository warehousingRepository)
        {
            this.warehousingRepository = warehousingRepository;
        }

        public async Task<int> Handle(WarehousingDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await warehousingRepository.GetModelAs(request.Id);
            info.IsDel = true;
            return await warehousingRepository.Update(info);
        }
    }
}
